package ads.client;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import ads.util.GameInfo;
import ads.util.PlayerInfo;

public class GameTableModel extends AbstractTableModel {

	private static final long serialVersionUID = 1L;
	private String[] columnNames = { "ID", "countOfPlayer" };

	private List<GameInfo> data;

	public List<GameInfo> getData() {
		return data;
	}

	public void setData(List<GameInfo> data) {
		this.data = data;
		fireTableDataChanged();
	}

	public int getColumnCount() {
		return columnNames.length;
	}

	public int getRowCount() {
		if (data != null)
			return data.size();
		else
			return 0;
	}

	public String getColumnName(int col) {
		return columnNames[col];
	}

	public Object getValueAt(int row, int col) {
		if (data == null)
			return null;
		GameInfo game = data.get(row);
		switch (col) {
		case 0:
			return game.getId();
		case 1:
			return game.getCountOfPlayer();
		default:
			return "";
		}
	}

	public Class getColumnClass(int c) {
		// return getValueAt(0, c).getClass();
		switch (c) {
		case 0:
			return Integer.class;
		case 1:
			return Integer.class;
		}
		return String.class;
	}

	

}
